package cinema.ELTEcinema;

import java.io.Serializable;

import javax.enterprise.context.SessionScoped;
import javax.inject.Inject;
import javax.inject.Named;

import cinema.ELTEcinema_ejb.Dao.UserDAO;
import cinema.ELTEcinema_ejb.Entity.User;

@SessionScoped
@Named
@SuppressWarnings("serial")
public class LoginBean implements Serializable {
	
	@Inject
	private UserDAO userDAO;
	
	private User activeUser;
	
	public boolean logIn(String uname, String password){
		User user = userDAO.validateUser(uname,password);
		if(user != null){
			activeUser = new User(user);
			return true;
		}
		return false;
	}

	public void logOut(){
		activeUser = null;
	}

	public User getActiveUser() {
		return activeUser;
	}
	
}
